package com.epam.edu.task01.tourism.residence;

import java.util.Date;

public class ResidenceInformation {
	private Date checkIn;

	private Date checkOut;
	private int costInOneDay;
	private String name;
	private Nutrition nutritionType;
	private ResidenceType residenceType;
	public ResidenceInformation(ResidenceType residenceType, String name,
			Nutrition nutritionType, int cost, Date checkIn, Date checkOut) {
		this.residenceType = residenceType;
		this.name = name;
		this.nutritionType = nutritionType;
		this.costInOneDay = cost;
		this.checkIn = checkIn;
		this.checkOut = checkOut;
	}

	public Date getCheckIn() {
		return checkIn;
	}

	public Date getCheckOut() {
		return checkOut;
	}

	public int getCostInOneDay() {
		return costInOneDay;
	}

	public int getCostOfResidence() {
		return (int) (this.getCostInOneDay() * getDaysCount(this.getCheckOut(),
				this.getCheckIn()));
	}

	long getDaysCount(Date lastDay, Date firstDay) {
		long millesecDifference = lastDay.getTime() - firstDay.getTime();
		long secondsDifference = millesecDifference / 1000;
		long minutesDifference = secondsDifference / 60;
		long hoursDifference = minutesDifference / 60;
		long daysDifference = hoursDifference / 24;
		return daysDifference + 1;
	}

	public String getName() {
		return name;
	}

	public Nutrition getNutritionType() {
		return nutritionType;
	}

	public ResidenceType getResidenceType() {
		return residenceType;
	}

	public void setCheckIn(Date checkIn) {
		this.checkIn = checkIn;
	}

	public void setCheckOut(Date checkOut) {
		this.checkOut = checkOut;
	}

	public void setCost(int cost) {
		this.costInOneDay = cost;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setNutritionType(Nutrition nutritionType) {
		this.nutritionType = nutritionType;
	}

	public void setResidenceType(ResidenceType residenceType) {
		this.residenceType = residenceType;
	}

	@Override
	public String toString() {
		return "ResidenceInformation [residenceType=" + residenceType
				+ ", name=" + name + ", nutritionType=" + nutritionType
				+ ", cost=" + costInOneDay + ", checkIn=" + checkIn
				+ ", checkOut=" + checkOut + "]";
	}
}
